package java67_14;

import java.util.Scanner;

public class CustTest {

	public static void main(String[] args) {

		CustManager cm = new CustManager();
		cm.name = "老刘";
		cm.tele = "13865997763";
		Scanner in = new Scanner(System.in);
		int ch = 0;
		while (true) {
			System.out.println("1:加新客户,2:查看客户 3:查找客户 4:修改客户姓名  5 按照范围查找  6:姓名排序   9:退出");
			ch = in.nextInt();
			if (ch == 1) {
				System.out.print("请输入客户姓名:");
				String name = in.next();
				cm.addCust(name);
			} else if (ch == 2) {
				cm.showCustomers();
			} else if (ch == 3) {
				System.out.print("请输入要查找的客户名:");
				String sname = in.next();
				boolean f = cm.search(sname);
				System.out.println(f ? "客户存在" : "客户不存在");
			} else if (ch == 4) {
				System.out.print("请输入要修改的客户名:");
				String sname = in.next();
				System.out.print("请输入新名字:");
				String newName = in.next();
				boolean m = cm.modify(sname, newName);
				if (m)
					System.out.println("修改成功");
				else
					System.out.println("修改失败,此客户不存在");
			} else if (ch == 5) {
				System.out.print("请输入要查找的客户名:");
				String sname = in.next();
				System.out.print("请输入起点:");
				int s = in.nextInt();
				System.out.print("请输入终点:");
				int e = in.nextInt();

				boolean f = cm.searchByRange(s, e, sname);
				System.out.println(f ? "客户存在" : "客户不存在");
			} else if (ch == 6) {
				String[] ar = cm.sort();
				for (String s1 : ar)
					System.out.println(s1);
			} else if (ch == 9) {
				break;
			}
		}
	}

}
